// 这里是项目主文件，请在这里编写代码同样这也是最后执行的JS文件;
"use strict";//设置严格模式，可以避免一些潜在的错误，不需要可以删除该行

//作者b站账号：https://space.bilibili.com/473239155
const bili_url = "https://space.bilibili.com/473239155";

const defVideoListColumn = 6;

const i1 = setInterval(() => {
    const els = document.querySelectorAll(".feed-card");
    if (els.length === 0) return;
    clearInterval(i1);
    Util.addStyle(`@media (min-width: 1560px) and (max-width: 2059.9px) {
    .recommended-container_floor-aside .container > *:nth-of-type(n + 8) {
        margin-top: 0 !important;
    }
}`);
    const msg = "已移除首页推荐视频区域中的顶部空白";
    console.log(msg);
    Tip.successBottomRight(msg);
}, 500);

const videoListColumn = Util.getData("videoListColumn", defVideoListColumn);

const i2 = setInterval(() => {
    const el = document.querySelector(".recommended-container_floor-aside .container");
    if (el === null) return;
    clearInterval(i2);
    Util.addStyle(`@media (min-width: 1560px) and (max-width: 2059.9px) and (min-width: 1560px) and (max-width: 2059.9px) {
    .recommended-container_floor-aside .container {
        grid-column: span 5;
        grid-template-columns: repeat(${videoListColumn}, 1fr) !important;
    }
}
`);
}, 1000);

const i4 = setInterval(() => {
    const el = document.querySelector(".bili-feed4-layout");
    if (el === null) return;
    clearInterval(i4);
    Util.addStyle(`.bili-feed4-layout {
    padding-bottom: 100px;
}`);
    const msg = "已调整视频列表底部距离";
    console.log(msg);
    Tip.successBottomRight(msg);
}, 1000);


Util.addGMMenu("设置列数", () => {
    let input = prompt("请输入视频列表列数，范围2-13，默认为" + defVideoListColumn, defVideoListColumn.toString());
    if (input === null) return;
    input = input.trim();
    if (isNaN(input)) {
        return alert("请输入数字！");
    }
    input = Number.parseInt(input);
    if (input < 2 || input > 13) {
        return alert("请输入2-13之间的整数！");
    }
    Util.setData("videoListColumn", input);
    alert(`已将视频列表列数设置为${input}！\n刷新页面生效。\n如不生效，请反馈给作者。`);
});


Util.addGMMenu("查看设置的列数", () => {
    const videoListColumn = Util.getData("videoListColumn", defVideoListColumn);
    alert(`当前脚本视频列表列数为${videoListColumn}！\n如不生效，请刷新页面。再不行，请反馈给作者。`);
});

Util.addGMMenu("反馈作者", () => {
    window.open(bili_url, "_blank");
});
